<?php


/*
 * 	Codificado: 02-Noviembre-2011, 00:52
	Estado: Ajustado_Modelo_Actual(X) Funcionando()
 */

class Lineas_Accion_Model extends CI_Model{

	private $table = 'Lineas_Accion';

	function _required($required, $data)
	{
		foreach($required as $field)
		if(!isset($data[$field])) return false;

		return true;
	}

	function Insertar($option = array()) {
		if ($this->_required(array('Nombre' ), $options)) return FALSE ;

		$this->db->insert($this->table, $options);
		return $this->db->insert_id();

	}

	function Editar($options = array()) {
		if(!$this->_required(array('Id'),$options))
		return FALSE;

		unset($options['submit'] );

		if(isset($options['Nombre']))
		$this->db->set('Nombre', $options['Nombre']);

		$this->db->where('Id', $options['Id']);
		$this->db->update($this->table, $options);

		return $this->db->affected_rows();
	}

	function Eliminar($options = array()) {

		$this->db->where('Id', $options['Id']);
		$this->db->delete($this->table);

		if($data['error'] = $this->db->_error_message());

		return $data;

	}

	function Ver($options = array()) {

		$query = $this->db->get($this->table);

		return $query->result_array();
	}

	function Listar($options = array()) {

		$query = $this->db->get($this->table);

		return $query->result_array();
	}


}